<template>
  <view :style="themeColor">
    <view class="page">
      <view class="flex benben-position-layout flex flex-wrap align-center changeNickname_flex_0"
        :style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
        <view class='flex align-center justify-between flex-sub changeNickname_fd0_0'>
          <view class='flex flex-wrap align-center changeNickname_fd0_0_c0'>
            <text class='changeNickname_fd0_0_c0_c0' @tap.stop="handleJumpDiy" data-type="back"
              data-url="1">{{$t('取消')}}</text>
          </view>
          <text class='self-center changeNickname_fd0_0_c1'>{{$t('修改昵称')}}</text>
          <view class='flex flex-wrap align-center justify-end changeNickname_fd0_0_c2'>
            <text class='changeNickname_fd0_0_c2_c0' @tap.stop="confirmModificationFunc()">{{$t('保存')}}</text>
          </view>
        </view>

      </view>
      <view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
      <!---flex布局flex布局开始-->
      <view class="flex flex-direction flex-wrap align-stretch benben-flex-layout changeNickname_flex_1">
        <view class='flex flex-wrap align-center justify-between changeNickname_fd1_0'>
          <input class='changeNickname_fd1_0_c0' type="text" :placeholder="$t('请输入昵称')" confirm-type="done"
            :maxlength="24" placeholder-style="color:rgba(191, 191, 191, 1);font-size:32rpx" v-model="data.nickname" />
        </view>
        <text class='changeNickname_fd1_1'>{{$t('请设置2-24个字符，不包含@《/等无效字符哦')}}</text>
      </view>

      <!---flex布局flex布局结束-->


    </view>
  </view>
</template>
<script>
  import {
    validate
  } from '@/common/utils/validate.js'
  export default {
    components: {},


    data() {
      return {
        "modificationName": {
          "userinfo": {
            "id": "",
            "avatar": "",
            "real_name": "",
            "nickname": "",
            "email": "",
            "gender": "",
            "mobile": "",
            "birthday": "",
            "client_id": "",
            "phone": ""
          }
        },
        "userNick": "",
        "data": {
          "invite_code": "",
          "address": "",
          "address_code": "",
          "hobby": "",
          "tags": "",
          "id": "",
          "userlevel_id": "",
          "mobile": "",
          "real_name": "",
          "avatar": "",
          "account": "",
          "email": "",
          "birthday": "",
          "gender": "",
          "create_time": "",
          "user_money": "",
          "freeze_money": "",
          "total_consumption_money": "",
          "score": "",
          "_mobile": "",
          "coupon": "",
          "collection_count": "",
          "browse_count": "",
          "total_money": "",
          "certified": "",
          "nickname": "",
          "is_pay_password": "",
          "follow_count": "",
          "is_close": ""
        },
        "nickname": ""
      };
    },
    computed: {
      themeColor() {
        return this.$store.getters.themeColor
      },

    },
    watch: {},
    onLoad(options) {
      let {
        nickname
      } = options
      if (nickname !== undefined) this.nickname = nickname
      this.getDataFunc()
    },
    onUnload() {

    },
    onReady() {

    },
    onShow() {

    },
    onHide() {

    },
    onResize() {

    },
    onPullDownRefresh() {

    },
    onReachBottom(e) {

    },
    onPageScroll(e) {

    },
    methods: {
      //确定修改
      async confirmModificationFunc() {
        if (!validate(this.data.nickname, 'require')) {
          this.$message.info(global.i18n.t('昵称不能为空'));
          return false;
        }
        if (this.data.nickname.length < 2) {
          this.$message.info(global.i18n.t('请设置2-24个字符，不包含@《/等无效字符哦'));
          return false;
        }
        uni.$emit('username', this.data.nickname)
        uni.navigateBack()
        return
        //请求方法
        //数据验证

        let datamodificationName = await this.$api.post(global.apiUrls.post5cb54af125f1c, {
          nickname: this.data.nickname
        });

        if (datamodificationName.data.code != 1) {
          this.$message.info(datamodificationName.data.msg);
          return
        }
        let infomodificationName = datamodificationName.data;
        this.modificationName = infomodificationName.data

        setTimeout(() => {
          this.$message.info('修改成功');
          this.$urouter.navigateBack(1);
        }, 800)
      },
      //清除昵称
      cleanNicknameFunc() {
        this.modificationName = '';
      },
      //获取会员
      async getDataFunc() {
        //请求方法
        //数据验证

        let datadata = await this.$api.get(global.apiUrls.post5c78c4772da97, {

        });

        if (datadata.data.code != 1) {
          this.$message.info(datadata.data.msg);
          return
        }
        let infodata = datadata.data;
        this.data = infodata.data

      }
    }
  };
</script>
<style lang="scss" scoped>
  .page {
    width: 100vw;
    overflow-x: hidden;
    min-height: calc(100vh - var(--window-bottom));
    background: rgba(247, 243, 237, 1);
    background-size: 100% auto;
  }

  .changeNickname_flex_0 {
    background: rgba(247, 243, 237, 1);
    width: 750rpx;
    height: 88rpx;
    overflow: hidden;
    z-index: 10;
    top: 0rpx;
    background-size: 100% auto !important;
  }

  .changeNickname_fd0_0_c2_c0 {
    background: rgba(145, 47, 34, 1);
    width: 114rpx;
    height: 64rpx;
    text-align: center;
    line-height: 64rpx;
    color: rgba(255, 255, 255, 1);
    font-size: 32rpx;
    font-weight: 500;
    background-size: 100% auto;
    border-radius: 44rpx;
  }

  .changeNickname_fd0_0_c2 {
    width: 144rpx;
  }

  .changeNickname_fd0_0_c1 {
    color: #333333;
    font-size: 36rpx;
    font-weight: 700;
  }

  .changeNickname_fd0_0_c0_c0 {
    color: #666666;
    font-size: 28rpx;
    font-weight: 400;
    line-height: 36rpx;
  }

  .changeNickname_fd0_0_c0 {
    width: 140rpx;
  }

  .changeNickname_fd0_0 {
    padding: 0rpx 32rpx 0rpx 32rpx;
  }

  .changeNickname_flex_1 {
    padding: 28rpx 32rpx 0rpx 32rpx;
  }

  .changeNickname_fd1_1 {
    color: #987040;
    font-size: 26rpx;
    font-weight: 400;
    line-height: 42rpx;
    margin: 32rpx 0rpx 0rpx 0rpx;
  }

  .changeNickname_fd1_0_c0 {
    color: rgba(51, 51, 51, 1);
    font-size: 32rpx;
  }

  .changeNickname_fd1_0 {
    background: rgba(255, 255, 255, 1);
    padding: 16rpx 0rpx 16rpx 24rpx;
    background-size: 100% auto;
    border-radius: 16rpx;
  }
</style>